package gui;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GuiLauncher extends JApplet{
	private JSpinner playerCount;
	private JLabel numPlayers;
	private JButton startGame, cancelGame;
	private JLabel[] playerNames;
	private JTextField[] playerInput;
	private GridLayout mainLayout;
	private JPanel mainPanel;
	private final int MAX_PLAYERS =8;
	public void init(){
		playerCount= new JSpinner(new SpinnerNumberModel(2,2,MAX_PLAYERS,1));
		numPlayers = new JLabel("Select number of players");
		startGame = new JButton("Start!");
		cancelGame = new JButton("Cancel");
		playerNames = new JLabel[MAX_PLAYERS];
		playerInput = new JTextField[MAX_PLAYERS];
		for(int i = 0;i<MAX_PLAYERS;i++){
			playerNames[i] = new JLabel("Player"+i+" name:");
			playerInput[i] = new JTextField("Unnamed"+i);
		}
		mainLayout = new GridLayout(6,2);
		mainPanel = new JPanel(mainLayout);
		mainPanel.add(numPlayers);
		mainPanel.add(playerCount);
		for(int i =0; i<8;i++){
			mainPanel.add(playerNames[i]);
			mainPanel.add(playerInput[i]);
		}
		mainPanel.add(startGame);
		mainPanel.add(cancelGame);
		cancelGame.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.exit(0);	//if not starting a game, then quit
			}
		});
		
	}
	public void stop(){
		System.exit(0);
	}
}
